package com.soft.dao;

import java.io.Serializable;
import java.util.List;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;

import com.soft.support.Pager;

@SuppressWarnings("rawtypes")
public interface BaseDao {
	/**
     * 保存实体.
     */
	public void save(Object o);
	
	/**
     * 更新实体.
     */
	public void update(Object o);

	/**
     * 保存或更新实体.
     */
	public void saveOrUpdate(Object o);

	/**
     * 删除实体.
     */
	public void delete(Object o);
	
	/**
	 * 删除实体(ID).
	 */
	public void delete(Class c, Serializable id);
	
	/**
	 * 获取实体.
	 */
	public Object get(Class c, Serializable id);
	
	/**
     * 根据属性值查询单个对象.
     */
	public Object findUniqueByProperty(final Class c, final String propertyName, final Object value);
	
	/**
     * 查询全部记录列表.
     */
    public List findAll(final Class c, final Order[] orders, final Criterion ...criterions);
    
    /**
     * 查询列表.
     */
    public List findByCriteria(final Class c, final Order[] orders, final int firstResult, final int maxResults, final Criterion ...criterions);
    public List findByCriteria(final Class c, final Order[] orders, final int firstResult, final int maxResults, final List<Criterion> criterions);
    
    /**
     * 查询总记录数.
     */
    public int findCountsByCriteria(final Class c,final Criterion ...criterions);
    public int findCountsByCriteria(final Class c,final List<Criterion> criterions);
    
    /**
     * 分页查询.
     */
    public Pager findForPager(final Class c, final Order[] orders, final int firstResult, final int maxResults, final Criterion ...criterions);
    public Pager findForPager(final Class c, final Order[] orders, final int firstResult, final int maxResults, final List<Criterion> criterions);
    
    /**
     * 根据属性值查询列表.
     */
    public List findByProperty(final Class entityClass, final Order[] orders, final String propertyName, final Object value);
    
    /**
     * 根据属性值查询实体是否存在.
     */
    public boolean isPropertyExist(final Class c, final String propertyName, final Object value);
    
    public Object execSQL(String sql);

}
